#include "view_time_13.h"
#include "view_time_12.h"
#include "view_time_13.inc"
#include "view_time_0.h"
#include "display_ctrl.h"
#include "platform_assert.h"
#include "lfs_file_manager_auto.h"
#include "rtc.h"
#include "datetime.h"
#include "blecom.h"
#include "battery_ctrl.h"
#include "sport_his.h"
#include "display_ctrl.h"
#include "display_interface_240x240.h"
#include "datetime.h"
#include "heart_rate_interface.h"
#include "font/num_font.h"
#include "font_mngr.h"
#include "view_common.h"
#include "app_trace.h"
#include "view_times.h"
#include "math.h"
#include "weather_ctrl.h"
#include "view_time_8.h"
#ifdef TIME_13_SKIP
#else
void view_time_13_display(void)
{
    int hour = disp_ctrl.com_data.i_temp[3];
    if (hour > 24 || hour < 0)
    {
        hour = 0;
    }
    int minute = disp_ctrl.com_data.i_temp[4];
    if (minute > 59 || minute < 0)
    {
        minute = 0;
    }
    // bool is_ble_connect = disp_ctrl.com_data.i_temp[6];
    // bool is_charge = disp_ctrl.com_data.i_temp[8];
    // int battery = disp_ctrl.com_data.i_temp[7];
    int month = disp_ctrl.com_data.i_temp[1];
    if (month > 12 || month < 0)
    {
        month = 0;
    }
    int day = disp_ctrl.com_data.i_temp[2];
    if (day > 31 || day < 0)
    {
        day = 0;
    }
    int week = disp_ctrl.com_data.i_temp[5]; // 1-7,星期天=7
    if (week > 7 || week < 1)
    {
        week = 1;
    }
#ifdef USE_CT1711
    // float wrist = disp_ctrl.com_data.f_temp[25];
    // float body = disp_ctrl.com_data.f_temp[26];
#else
#error no temperature
#endif
    int heart_rate = disp_ctrl.com_data.i_temp[17];
    int steps = disp_ctrl.com_data.i_temp[11];
#if 0
#warning debug
    heart_rate = 220;
    steps = 99999;
#endif
    show_time_0_battery(disp_ctrl.com_data.i_temp[7], disp_ctrl.com_data.i_temp[8]);
    show_time_0_ble();
    int x = 110;
    int y = 36;
    disp_draw_user_image(x, y, num_30x61_colon);
    x = 21;
    disp_draw_user_image_gray_lucency(x, y, 0x8ffe, num_30x61_TAB[hour / 10]);
    x += 43;
    disp_draw_user_image_gray_lucency(x, y, 0x8ffe, num_30x61_TAB[hour % 10]);
    x = 136;
    disp_draw_user_image(x, y, num_30x61_TAB[minute / 10]);
    x += 43;
    disp_draw_user_image(x, y, num_30x61_TAB[minute % 10]);
    x = 64;
    y = 112;
    disp_draw_user_image_num_with_digits(x, y, month, 2, 11, num_10x15_TAB);
    x += 22;
    disp_draw_user_image(x, y, num_10x15_slash);
    x += 8;
    disp_draw_user_image_num_with_digits(x, y, day, 2, 11, num_10x15_TAB);
    x += 29;
    disp_draw_user_image(x, y, week_52x15_TAB[week - 1]);
    x = 13;
    y = 154;
    disp_draw_user_image(x, y, icon_wrist_44x44);
    x = 93;
    y = 154;
    disp_draw_user_image(x, y, icon_body_44x44);
    x = 165;
    y = 169;
    disp_draw_user_image(x, y, icon_heart_rate_18x17);
    x = 165;
    y = 204;
    disp_draw_user_image(x, y, icon_steps_18x17);
    x = 187;
    y = 170;
    disp_draw_user_image_num(x, y, heart_rate, 10, num_10x16_TAB);
    x = 187;
    y = 206;
    disp_draw_user_image_num(x, y, steps, 10, num_10x16_TAB);
    x = 3;
    y = 204;
    view_time_show_temperature_float_with_font(x, y, disp_ctrl.com_data.f_temp[25], disp_ctrl.com_data.i_temp[21] == WEATHER_TEMPERATURE_TYPE_C, true, num_10x16_TAB, 1, 1, 7);
    x = 84;
    y = 204;
    view_time_show_temperature_float_with_font(x, y, disp_ctrl.com_data.f_temp[26], disp_ctrl.com_data.i_temp[21] == WEATHER_TEMPERATURE_TYPE_C, true, num_10x16_TAB, 1, 1, 7);
}
#endif
